/* CustomerController.java
 *
 * Copyright (C) 2013 Universidad de Sevilla
 * 
 * The use of this project is hereby constrained to the conditions of the 
 * TDG Licence, a copy of which you may download from 
 * http://www.tdg-seville.info/License.html
 * 
 */

package controllers;

import java.util.Collection;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import services.CustomerService;
import domain.Customer;

@Controller
@RequestMapping("/customer")
public class CustomerController extends AbstractController {

	//Services -----------------------------------------------------------------
	
	@Autowired
	CustomerService customerService;
	
	// Constructors -----------------------------------------------------------

	public CustomerController() {
		super();
	}
	
	//List --------------------------------------------------------------------
	
	@RequestMapping("/list")
	public ModelAndView list() {
		ModelAndView result;
		Collection<Customer> customers;
		customers = customerService.findAll();
		
		
		result = new ModelAndView("customer/list");
		result.addObject("customers", customers);
		return result;
	}

	
}